package com.baicaierp.baicaimp.po;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.social.security.SocialUserDetails;

import java.util.Collection;
import java.util.Date;

/**
 * @Description
 * @Author: Fanxl
 * @Date: Created in 2017/9/18 12:59
 */
@Data
public class Operator implements SocialUserDetails {

    private String id;

    private String name;

    private String code;

    private String password;

    private String email;

    private String mobile;

    private String remark;

    private Date createTime;

    private String companyId;

    private String openId;

    private Date endTime;

    private Date startTime;

    private String accountSuite = "1234cj";

    private String photo;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return AuthorityUtils.commaSeparatedStringToAuthorityList("admin");
    }

    @Override
    public String getUsername() {
        return code;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String getUserId() {
        return getAccountSuite() + ":" + getId();
    }
}
